<?php
  require_once('nav.php');
  //用户id是通过GET方法提交的   
   //根据用户id从数据库中查询用户的所有信息
   $id = $_GET['id'];  
   $sql = "select * from users where uid={$id}";   
   $result = mysql_query($sql) or die('查询失败！'.mysql_error());   
   $row = mysql_fetch_assoc($result);
   //$row = fetch_one($sql);
   //var_dump($row);   
   $uname = $row['uname'];
   $gender = $row['gender'];
   $birthdate = $row['birthdate'];
   $hobby = $row['hobby'];
   $degree = $row['degree'];
   $intro = $row['intro'];
   $pic = UserPhotoPath.$row['pic'];
?>
 <div class="col-sm-9 col-md-10">
    <h2 class="text-center">用户编辑</h1>
    <form method="post" action="userUpdate.php" 
     enctype="multipart/form-data" class="form-horizontal">
      <input type="hidden" name="id" 
      value="<?php echo $id;?>">
      <div class="form-group">
        <label for="uname" class="col-md-2 col-xs-3 control-label">用户名</label>
        <div class="col-md-10 col-xs-9">
          <input type="text" class="form-control" id="uname" placeholder="用户名" name="uname" 
          value="<?php echo $row['uname']; ?>">
        </div>
      </div>

      <div class="form-group">
        <label for="password" class="col-md-2 col-xs-3 control-label">密码</label>
        <div class="col-md-10 col-xs-9">
          <input type="password" class="form-control" id="password" placeholder="密码" name="password" 
          value="<?php echo $row['password']; ?>">
        </div>
      </div>

      <div class="form-group">
            <label class="col-md-2 col-xs-3 control-label" for="gender">性别</label>
            <div class="col-md-10 col-xs-9">
              <label class="radio-inline">
                <input name="gender" type="radio" value="0" id="gender" 
                <?php 
                  //echo $gender==0?'checked':'';
                  if($gender==0){echo 'checked';}
                ?>>男
              </label>
              <label class="radio-inline">
                <input name="gender" type="radio" value="1"
                 <?php 
                  //echo $gender==1?'checked':'';
                  if($gender==1){echo 'checked';}
                ?>>女
              </label>
            </div>
          </div>


          <div class="form-group">
            <label class="col-md-2 col-xs-3 control-label" 
            for="hobby">爱好</label>
            <div class="col-md-10 col-xs-9">
              <label class="checkbox-inline">
                <input name="hobby[]" type="checkbox" 
                value="旅游" id="hobby" 
                <?php 
                  if(strstr($hobby,'旅游')){echo 'checked';}
                ?>>旅游
              </label>
              <label class="checkbox-inline">
                <input name="hobby[]" type="checkbox" value="登山" id="hobby" 
                <?php 
                  if(strstr($hobby,'登山')){echo 'checked';}
                ?>>登山
              </label>
             
            </div>
          </div>

    </form>
 </div>
<?php
  require_once('footer.php');
?>